﻿@using LightSO.CMS.Model.EasyUI

@{
    Treegrid Treegrid = null;
    if (ViewBag.Treegrid == null)
    {
        Treegrid = LightSO.CMS.Model.EasyUI.Treegrid.Create(ViewBag);
    }
    else
    {
        Treegrid = ViewBag.Treegrid;
    }
    string version = "20150605";
}


<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>@ViewBag.Title</title>
    @Html.Partial("~/Views/Shared/Shared.cshtml")

    <script type="text/javascript">
    @RenderSection("EnumDefine", false)
        var columns_@(Treegrid.Id) = [
            @if(Treegrid.Columns.Count>0)
        {
        @:[
                    var i = 0;
            foreach (var item in Treegrid.Columns)
            {
                Column col = item.Value;
                @:{
                    @:  field: '@(col.Id)', title: '@(col.Title)', width: @(col.Width), hidden: @((col.Id == "Id" ? "false" : (col.Hidden ? "true" : "false"))), sortable: @(col.Sortable ? "true" : "false"), align: '@(col.Align.ToString().ToLower())',nowrap: @(col.NoWrap ? "true" : "false"),
                    @:  formatter: function(value, row, index){
                                                        string columnName = col.Id;
                        if (!string.IsNullOrWhiteSpace(columnName))
                        {
                            var script = RenderSection(string.Format("{0}ColumnFormat", columnName), false);
                            if(script != null)
                            {
                                System.Text.RegularExpressions.Regex regex = new System.Text.RegularExpressions.Regex(@"</?script[^<>]*>");
                                @Html.Raw(regex.Replace(script.ToHtmlString(), string.Empty));
                                @:value = this.formatter(value, row, index);
                                                            }
                        }
                        @:return typeof(value) != "string" && value == 0 ? "" : value;
                                                   @:}
                                    @:}
                        i++;
                if (i != Treegrid.Columns.Count)
                {
                    @:,
                        }
            }
        @:]
                }
        ];

        var rowStyler_@Treegrid.Id = function (index, row) {
                @{
                    var rowStyler = RenderSection("RowStyler", false);
                    if (rowStyler != null)
                    {
                        System.Text.RegularExpressions.Regex regex = new System.Text.RegularExpressions.Regex(@"</?script[^<>]*>");
                        @Html.Raw(regex.Replace(rowStyler.ToHtmlString(), string.Empty));
                        @:return this.rowStyler(index, row);
                    }
                }
        };

        var onClickRowEvent_@Treegrid.Id = function (index, row) {
                @{
                    var onClickRowEvent = RenderSection("OnClickRow", false);
                    if (onClickRowEvent != null)
                    {
                        System.Text.RegularExpressions.Regex regex = new System.Text.RegularExpressions.Regex(@"</?script[^<>]*>");
                        @Html.Raw(regex.Replace(onClickRowEvent.ToHtmlString(), string.Empty));
                        @:this.onClickRow(index, row);
                    }
                }
        };

        var onDblClickRowEvent_@Treegrid.Id = function (index, row) {
                @{
                    var onDblClickRowEvent = RenderSection("OnDblClickRow", false);
                    if (onDblClickRowEvent != null)
                    {
                        System.Text.RegularExpressions.Regex regex = new System.Text.RegularExpressions.Regex(@"</?script[^<>]*>");
                        @Html.Raw(regex.Replace(onDblClickRowEvent.ToHtmlString(), string.Empty));
                        @:this.onDblClickRow(index, row);
                    }
                }
        };

        $(function () {
            easymvc.createTreegrid('@(Treegrid.Id)', '@(Html.Raw(Treegrid.Url))',easymvc.view);
        });
    </script>
    @if (!string.IsNullOrWhiteSpace(Treegrid.ScriptSrc))
    {
        <script type="text/javascript" src="@Treegrid.ScriptSrc?version=@version"></script>
    }
</head>
<body class="easyui-layout" style="margin:1px">
    <div id="menuDataGridContent" data-options="region:'center',title:'菜单树',split:true,iconCls:'icon-standard-application-side-tree'">
        <table id="@(Treegrid.Id)"></table>
        <form id="FrmSysMenuInfo_Dialog" method="post" style="display:none">
            <input type="hidden" name="Id" id="hidId" />
            <input type="hidden" name="Path" id="hidPath" />
            <input type="hidden" name="ParentId" id="hidParentId" />
            <input type="hidden" name="NodeLevel" id="hidNodeLevel" />
            <div style="padding:15px 35px 35px 25px">
                <div id="lblTitle" class="ftitle"></div>

                <table style="width:100%" cellpadding="2" cellspacing="2" border="0">
                    <tr>
                        <td width="70">
                            菜单图标:
                        </td>
                        <td colspan="3">
                            <input type="hidden" id="hidIconClass" name="IconClass" value="" />
                            <a href="#" class="easyui-linkbutton" id="btnChooseImgMenu">选择图标</a>
                            <img id="imgIconClass" class="iconImg icon-blank" style="vertical-align:middle;border:0" />
                        </td>
                    </tr>
                    <tr>
                        <td width="70">
                            菜单名称:
                        </td>
                        <td colspan="3">
                            <input type="text" id="Name" name="Name" maxlength="80" style="width: 99%;" class="easyui-validatebox" validtype="length[2,30]" />
                        </td>
                    </tr>
                    <tr>
                        <td width="70">
                            URL地址:
                        </td>
                        <td colspan="3">
                            <input type="text" id="Url" name="Url" maxlength="80" style="width: 99%;" class="easyui-validatebox" validtype="length[10,256]" />
                        </td>
                    </tr>
                    <tr>
                        <td width="70">
                            排序号:
                        </td>
                        <td>
                            <input type="text" id="Sequence" name="Sequence" value="" class="easyui-validatebox numeral" maxlength="10" style="width: 40px" data-options="validType:'Integer'" />
                        </td>
                        <td width="70">
                            菜单状态:
                        </td>
                        <td>
                            <label><input type="radio" name="Status" value="" />{0}</label>&nbsp;&nbsp;&nbsp;&nbsp;
                        </td>
                    </tr>
                    <tr>
                        <td>
                            详细说明:
                        </td>
                        <td colspan="3">
                            <div>
                                <textarea name="Description" rows="3" style="width: 99%" class="easyui-validatebox" req="false"></textarea>
                            </div>
                        </td>
                    </tr>
                    <tr>
                        <td></td>
                        <td colspan="3">
                            <label title="有些模块只需进行权限控制，不必在菜单中显示"><input type="checkbox" id="IsVisible" name="IsVisible" value="true" />菜单</label>&nbsp;&nbsp;&nbsp;&nbsp;
                            <label title="涉及敏感或重要的功能项，以便在授权时提醒注意"><input type="checkbox" id="IsSensitive" name="IsSensitive" value="true" />敏感</label>&nbsp;&nbsp;&nbsp;&nbsp;
                            <label title="对Ajax页的权限是通过关联按钮进行控制的"><input type="checkbox" id="IsAjaxApi" name="IsAjaxApi" value="true" />Is Ajax Api</label>
                        </td>
                    </tr>
                    <tr>
                        <td></td>
                        <td colspan="3">
                            <label title="无须权限控制，所有顾问都可以访问谓之公开"><input type="checkbox" id="IsPublic" name="IsPublic" value="true" />公开</label>
                            <font color="red">(如果要控制页面按钮权限，不可勾选此项)</font>
                        </td>
                    </tr>

                </table>
            </div>
        </form>
    </div>
    <div id="controlDataGrid" data-options="region:'east',title:'控件列表',split:true,collapsed:true,iconCls:'ext-icon-application_view_tile'" style="width:700px;">
        <table id="tableControl"></table>
    </div>

    @RenderBody()

    @*右键菜单*@
    <div id="popupmenu_@(Treegrid.Id)" class="easyui-menu" style="width:120px;">
        @RenderSection("PopupMenu", required: false)
        <div class="menu-sep"></div>
        <div id="menuItemReload" onclick="easymvc.treegridReload('@(Treegrid.Id)');" data-options="iconCls:'icon-reload'">刷新</div>
    </div>

    @*工具条面板组*@
    <div id="treegrid_toolbar_@(Treegrid.Id)" style="display:none;">
        @*按钮组*@
        @{var buttons = RenderSection("ToolbarButtonsGroup", false);}
        @if (buttons != null)
        {
            <div class="treegrid-toolbar">
                @Html.Raw(buttons.ToHtmlString())
            </div>
        }
        @{var filter = RenderSection("ToolbarFilter", false);}
        @if (filter != null)
        {
            <div class="treegrid-toolbar">
                @Html.Raw(filter.ToHtmlString())
            </div>
        }
        @*工具条菜单*@
        <div class="treegrid-toolbar" style="border-bottom-width:0px;">
            @RenderSection("ToolbarMenu", false)
            <a id="btnTreegridReload" onclick="easymvc.treegridReload('@(Treegrid.Id)');" href="#" class="easyui-linkbutton" data-options="iconCls:'icon-reload',plain:true">刷新</a>
        </div>
    </div>

    <div id="toolbarControl" style="display:none">
        @RenderSection("ControlToolbarMenu", false)
        <span class="datagrid-btn-separator"></span>
        <a href="javascript:void(0)" class="easyui-linkbutton" iconcls="icon-reload" plain="true" onclick="easymvc.reloadAllButtons();">刷新</a>
    </div>
    <div id="controlOperates" class="easyui-menu" style="width:120px;">
        @RenderSection("ControlPopupMenu", required: false)
        <div class="menu-sep"></div>
        <div onclick="easymvc.reloadAllControl();" data-options="iconCls:'icon-reload'">刷新</div>
    </div>  
</body>
</html>
